# Contributor: Bjoern Schilberg <bjoern@intevation.de>
# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=mapserver
pkgver=8.2.2
pkgrel=0
pkgdesc="CGI-based platform for publishing spatial data and interactive mapping applications to the web"
url="https://mapserver.org/"
# s390x: blocked by exempi-dev
arch="all !s390x"
license="MIT"
depends_dev="
	cairo-dev
	curl-dev
	exempi-dev
	fcgi-dev
	freetype-dev
	fribidi-dev
	gdal-dev
	geos-dev
	giflib-dev
	harfbuzz-dev
	jpeg-dev
	libpq-dev
	librsvg-dev
	libxml2-dev
	pixman-dev
	proj-dev
	protobuf-c-dev
	"
makedepends="
	$depends_dev
	cmake
	samurai
	"
subpackages="
	$pkgname-dev
	"
source="
	https://download.osgeo.org/mapserver/mapserver-$pkgver.tar.gz
	10-musl.patch
	"

build() {
	CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DWITH_GEOS=ON \
		-DWITH_POSTGIS=ON \
		-DWITH_KML=ON \
		-DWITH_WCS=ON \
		-DWITH_SOS=ON \
		-DWITH_WMS=ON \
		-DWITH_CLIENT_WMS=ON \
		-DWITH_WFS=ON \
		-DWITH_CLIENT_WFS=ON \
		-DWITH_THREAD_SAFETY=OFF \
		-DWITH_FCGI=ON \
		-DWITH_CAIRO=ON \
		-DWITH_RSVG=ON \
		-DWITH_CURL=ON \
		-DWITH_MYSQL=OFF \
		-DWITH_FRIBIDI=ON \
		-DWITH_HARFBUZZ=ON \
		-DWITH_EXEMPI=ON \
		-DWITH_PROTOBUFC=ON \
		-DWITH_PIXMAN=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	# shellcheck disable=2115
	rm -rf "$pkgdir"/usr/share/
	chmod -x "$pkgdir"/usr/include/mapserver/*.h
}

sha512sums="
e91454c4f71931d6a6f8540191441cef0b7b9f5ad1d4ccf65ee504b1d84272cfe19900141846300f6bcaace2a70b919f1fd5b2a80158c38dfaef413b1ce01a22  mapserver-8.2.2.tar.gz
c63f5f061e3574b077ba9870d6997ca4c4c8896d87f2b371c23afa66d40df3589da301318d316d285a46886509f39e34a629140138694ba8e64aa28a367aa61f  10-musl.patch
"
